﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Runtime.Serialization;

namespace UtilityLibrary.Http
{
    [Serializable]
    public class HttpRecord
    {
        private WebHeaderCollection _requestHeaders;
        private WebHeaderCollection _responseHeaders;
        private HttpParamaterCollection _paramaters;
        public HttpRecord()
        {
            _requestHeaders = new WebHeaderCollection();
            _responseHeaders = new WebHeaderCollection();
            _paramaters = new HttpParamaterCollection();
        }

        /// <summary>
        /// 请求Url
        /// </summary>
        //public Uri RequestUrl { get; set; }

        /// <summary>
        /// 链接地址
        /// </summary>
        public String Link { get; set; }

        /// <summary>
        /// 请求方式
        /// </summary>
        public String Method { get; set; }

        /// <summary>
        /// 请求头信息
        /// </summary>
        public WebHeaderCollection RequestHeaders
        {
            get
            {
                return _requestHeaders;
            }
        }

        /// <summary>
        /// 响应头信息
        /// </summary>
        public WebHeaderCollection ResponseHeaders
        {
            get
            {
                return _responseHeaders;
            }
        }

        /// <summary>
        /// 请求参数列表
        /// </summary>
        public HttpParamaterCollection Paramaters
        {
            get
            {
                return _paramaters;
            }
        }

        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="paramaters"></param>
        public void SetParamaters(Dictionary<String, String> paramaters)
        {
            foreach (String key in paramaters.Keys)
            {
                _paramaters.Add(new HttpParamater(key, paramaters[key]));
            }
        }

        /// <summary>
        /// 响应正文
        /// </summary>
        public String ResponseContent { get; set; }

        /// <summary>
        /// 生成记录时间
        /// </summary>
        public DateTime RecordTime { get; set; }
    }
}
